<?php
    class Role_con extends CI_Controller{
        function __construct() {
            parent::__construct();
        }
        function index(){
            $this->list_role();
        }
        function list_role(){
            $query = $this->db->get('daftar_role');
            if($query->num_rows()>0){
                $this->load->library('table');
                $this->table->set_template(array('table_open' => '<table align="center" width="50%" border="1" cellpadding="1" cellspacing="1">'));
                $this->table->set_heading('NO', 'ROLE','AKSI');
                $i=1;
                foreach($query->result() as $entry){
                    $this->table->add_row(
                    $i,
                    $entry->NAMA_ROLE,
                    anchor('./admin/role_con/delete/'.$entry->ID_ROLE,'HAPUS')
                    );
                    $i++;
                }
                $display['content']=$this->table->generate();
            }else{
                $display['content']='Belum ada role yang dibuat';
            }
            $data['title']="List ROle";
            $this->load->view('admin/admin_header_view', $data);
            $this->load->view('admin/list_role', $display);
            $this->load->view('footer_view');
        }
        function add_role(){
            if($_POST['NAMA_ROLE']!='')
                $this->db->insert('daftar_role',$_POST);
            redirect('./admin/role_con');
        }
        function delete($id){
            $this->db->delete('daftar_role', array('ID_ROLE' => $id));
            redirect('./admin/role_con');
        }
    }
?>
